home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Surfer 2.0
/
Internet Surfer 2.0 (Wayzata Technology) (1996).iso
/
pc
/
text
/
mac
/
faqs.449
< prev
next >
Wrap
Text File
|
1996-02-12
|
28KB
|
755 lines
Frequently Asked Questions (FAQS);faqs.449
Please help fix the FAQ! All comments should be mailed to
jgm@cs.brown.edu. My favorite way to receive a change suggestion is
when it is accompanied by a section of the FAQ that is edited and
mailed to me verbatim as an example. If you would like to
contribute, please read the section ``about the FAQ'' first. Thank
you!
Books and programs are referred to by name only. See the
appropriate sections for full information.
Subject: 7 Programming in PostScript
Subject: 7.1 What is PostScript level 2?
PostScript Level Two is a major upgrade to PostScript Level One.
Starting from PostScript Level One as a basis, PostScript Level Two
represents the confluence of many features:
* Composite fonts -- fonts with the capability of supporting
character sets with more than 256 characters. Such fonts are
needed in the Asian marketplace, for example.
* Patterns -- provide a device-independent way to describe patterns
which tile an area. A pattern can be thought of as another kind
of ``color'' in PostScript Level Two.
* Forms -- to meet the demands of the forms market, forms describe
static information which can be repeated many times on one page
or printed on many separate pages, or both.
* Color -- the previous ill-defined color models are now enhanced
with the addition of CMYK color, support for color images, CIE
device-independent color (if anybody can understand the damned
thing).
* Halftones -- new highly accurate halftone screening methods to
meet the needs of high end typesetting equipment.
* Display PostScript -- many enhancements and efficiency
improvements to support the needs of screen rendering.
Enhancements include:
* efficient rectangle operators,
* efficient font and text operators,
* multiple contexts
* shared memory models
* hit detection
A detailed description of PostScript 2 is available in the section
on PostScript 2.
Subject: 7.2 Should I learn level 2 PostScript?
Yes, because Level Two will soon become the standard. Application
developers using PostScript need to become aware of the new
capabilities and how to take advantage of them.
There are many good books on PostScript 2. (See Section 5,
``Books''.)
Subject: 7.3 Where can I find examples of PostScript code?
Many other books on PostScript make example PostScript code
available. ``Thinking in PostScript'', by Glenn Reid, is the only
book I know of that allows its examples to be freely distributed.
(See Section 5, ``Books''.)
All the examples in ``the blue book'' are available from the Adobe
file server (See Section 5, ``Books''.)
See the question ``How can I browse through PostScript programs?''
in the section on utilities.
Subject: 7.4 How do I get the physical size of a page?
The initial clipping path gives you the size of the imagable area.
Use ``clippath pathbbox'' to get these coordinates. If you must
know the size of the device's imageable area, use the sequence
``gsave initclip clippath pathbbox grestore'', but this will
prevent an enclosing application from using the clippath to achieve
some special effects (such as multiple pages per page).
Subject: 7.5 Why can't I do a pathforall after a charpath ?
(See Section 4, ``Fonts'', question ``Why are Adobe fonts
hidden?''.)
Subject: 7.6 How do I center a string of text around a point?
Level 1 PostScript has two operators that can extract information
about the metrics of characters: ``stringwidth'' and ``charpath''.
The ``stringwidth'' operator returns the advance width of its
string operand. This is the distance the current point would be
moved by a ``show'' operation on the same string. ``stringwidth''
returns two numbers on the stack, representing the x and y
components of the advance width. Usually the y component is zero
because most fonts are displayed along a horizontal line, moving
the current point only in the x direction.
Also note that the ``stringwidth'' operator includes any side
bearings in its result. It usually does not give an exact measure
of the area of the page that will be touched by its operand.
If all that an application requires is horizontal centering of a
long string of text, the result returned by ``stringwidth'' is
sufficient. A common technique is
x y moveto
(string) dup stringwidth pop 2 div neg 0 rmoveto show
(This code makes the assumption that the y component of advance
width is irrelevant.)
The ``charpath'' operator extracts the graphic shapes of its string
operand and appends them to the current path in the graphic state.
These shapes can then be processed by other PostScript operators.
To get the actual size of the area touched by a character a simple
approach is
gsave
newpath
0 0 moveto
(X) true charpath flattenpath pathbbox
grestore
This code places four numbers on the stack, representing the
coordinates of the lower left and upper right corners of the
bounding box enclosing the character ``X'' rendered with the
current point at (0,0).
There are two things to be careful about when using the code shown
above:
1. There are severe limits on the size of the string operand,
related to the limit on the number of elements in a graphic path.
The PostScript Language Reference Manual recommends taking
``charpath''s one character at a time.
2. If user space is rotated or skewed with respect to device space,
the result from ``pathbbox'' may be larger than expected;
``pathbbox'' returns a rectangle oriented along the user space
coordinate axes, which fully encloses a (possibly smaller)
rectangle oriented along the coordinate axes of device space. If
user space is rotated at an integer multiple of 90 degrees these
two rectangles will be the same, otherwise the rectangle in user
space will be larger.
So, to center text vertically one must get the bounding boxes of
all the characters in the string to be displayed, find the minimum
and maximum y coordinate values, and use half the distance between
them to displace the text vertically.
If an application does this repeatedly, it would be wise to store
the bounding boxes in an array indexed by character code, since
``charpath'' is a slow operation.
Font metric information is available outside of a PostScript
printer in font metrics files, available from Adobe. A program
generating PostScript output can obtain metrics from these files
rather than extracting the metrics in the printer.
Subject: 7.7 How can I concatenate two strings together?
%% string1 string2 append string
% Function: Concatenates two strings together.
/append {
2 copy length exch length add % find the length of the new.
string dup % string1 string2 string string
4 2 roll % string string string1 string2
2 index 0 3 index
% string string string1 string2 string 0 string1
putinterval % stuff the first string in.
% string string string1 string2
exch length exch putinterval
} bind def
Subject: 7.8 What do I do when I get stack overflow/underflow?
|
| These errors are among the most common in PostScript.
|
| When I get a stack overflow, that is usually a sign that a routine
| is leaving an object on the stack. If this routine gets called 2000
| times, it leaves 2000 objects on the stack, which is too many.
|
| When I get a stack underflow, that is a sign that either: (A) one
| of the routines in the program doesn't work, and never has or (B)
| one of the routines in the program works, but expects to be called
| with some arguments left on the stack.
|
| There is no such thing as a PostScript debugger right now. For now,
| the best that you can do to debug your program is to put in lots of
| print statements. Learn to use the PostScript pstack command, and
| use an online interpreter so you don't have to run to the printer
| for each debugging cycle.
|
| Use an error handler to learn more about what exactly is happening
| when your program crashes. (see Section 12, ``PostScript
| Interpreters and Utilities'')
|
| If your code has never worked yet (i.e. you are still writing it)
| then I find that it helps to put little comments in the margin
| about the state of the stack. Like this:
|
|
| Heart pathbbox % lowerx lowery upperx uppery
| exch 4 -1 roll % lowery uppery upperx lowerx
|
|
| I generally put these comments in originally, and then take them
| out when the program works. Maybe this is a bad practice, in case I
| ever want to go back and look at the code to modify it!!
Subject: 7.9 The Obfuscated PostScript Contest
Alena Lacova and Jonathan Monsarrat are running an Obfuscated
PostScript Contest that will end on January 10th.
For information about the contest, write jgm@cs.brown.edu or ftp
the rules from wilma.cs.brown.edu:pub/postscript/rules.ps or
rules.txt.
Subject: 8 Computer-specific PostScript
This section describes PostScript information specific to a
particular type of computer or operating system.
Subject: 8.1 Sun Workstations
What is NeWS?
NeWS is Sun Microsystems PostScript-based window system for the Sun
Workstation. NeWS was a project within Sun (started around 1985) to
create a window system to supplant SunView (a very successful
kernel-based window system). NeWS is a client-server model window
system (like X) but among many of NeWS novel features was the use
of PostScript as the language to describe the appearance of objects
on the screen. Because there are few ways to design a knee joint,
NeWS has many features in common with Display PostScript, but NeWS
predates Adobe Display PostScript and was neither connected with
Adobe Display PostScript nor endorsed by Adobe. NeWS is not an
Adobe product, nor is it a Sun/Adobe joint venture.
NeWS had the potential to become a world-class window system had
not a coalition of computer vendors ganged together to endorse the
X window system from MIT, sending Sun into a frenzy to support both
X and NeWS in the same window server.
One respected engineer from DEC remarked they all feared Sun would
ignore the industry X coalition and go on to make NeWS a standard.
They were overjoyed when Sun reacted by taking on X and merging it
with NeWS, causing additional work which made it harder for Sun to
make progress with NeWS. oAlso it made X the de facto standard;
whether or not this is a good thing depends on who you talk to.
As of October 1992, Sun management signed a deal with Adobe to
adopt Display PostScript for the Sun. The future of NeWS is still
undecided (but it looks bad).
And how does PostScript run on them?
PostScript runs on NeWS. Due to lack of support from Sun
management, NeWS never made it as a fully-compliant PostScript
interpreter. There were incompatibilities between the NeWS
PostScript interpreter and ``official'' PostScript interpreters as
defined by Adobe and the Apple LaserWriter family of printers, such
that many PostScript files which would print fine on a LaserWriter
would not render under NeWS. The most critical incompatibility was
the lack of support for Adobe Type 1 fonts, Sun having gone with
their own font format known as F3. Given the NeWS PostScript
interpreter was not even PostScript Level One compliant, the
chances of bringing NeWS to Level Two compliance was remote,
lending further to NeWS decline.
Subject: 8.2 IBM PC
You can find nenscript for OS/2 1.x--2.0 and MSDOS on
ftp-os2.nmsu.edu in pub/uploads/nensc113.zip.
| There are rumors that Word Perfect and Microsoft Word don't produce
| ``clean'' PostScript that follows the DSC conventions (See Section
| 9, ``Encapsulated PostScript''). This means that a lot of
| PostScript utilities like Ghostview and psnup, etc., that require
| the DSC conventions, will not work on them.
|
| Creating a PostScript file from MS Word
|
| Install the LaserWriter driver that comes with Windows.In the
| printer setup, select a PostScript printer. Then click on the setup
| button to get that pop-up. Then clik the Options button. Then
| select the print to Encapsulated PostScript File. If you don't
| specify a file name, Word will prompt you for one when you tell it
| to print.
|
| When printing Microsoft Windows files that have been captured on a
| PC's LPT port, you mostly need to define two ctrl-d's in a row as
| well to remove all of them in the document:
|
|
| (\004\004) cvn \{\} def
Subject: 8.3 Apple Macintosh
For more details about printing with the Macintosh, read the
comp.sys.mac.apps FAQ.
How can I convert a PostScript file created with a UNIX program to
the Mac?
A way that is clumsy, but works, is this:
1. Display the UNIX-based PostScript file on screen
2. Use window dumping facility to get a bitmap file
3. Convert the above bitmap file to TIFF format and then export it
to Adobe Illustrator on the Mac.
The PostScript section of the FAQ for the Macintosh newsgroup
comp.sys.mac.app (maintained by Elliotte Harold) answers the
following questions:
* How do I make a PostScript file?
* How do I print a PostScript file?
* Why won't my PostScript file print on my mainframe's printer?
Full documentation of this process provided with a utility called
macps.
* Why are my PostScript files so big?
Subject: 9 Encapsulated PostScript
Subject: 9.1 What is Encapsulated PostScript?
| Encapsulated PostScript (EPS) is a standard format for importing
and exporting PostScript language files in all environments. It is
usually a single page PostScript language program that describes an
illustration. The purpose of the EPS file is to be included as an
illustration in other PostScript language page descriptions. The
EPS file can contain any combination of text, graphics, and images.
An EPS file is the same as any other PostScript language page
description, with some restrictions.
EPS files can optionally contain a bitmapped image preview, so that
systems that can't render PostScript directly can at least display
a crude representation of what the graphic will look like. There
are three preview formats: Mac (PICT), IBM (tiff), and a platform
independent preview called EPSI.
An EPS file must be a conforming file, that is, it must conform to
the Adobe Document Structuring Conventions (DSC). At a minimum, it
must include a header comment,%!PS-Adobe-3.0 EPSF-3.0, and a
bounding box comment,%%BoundingBox: llx lly urx ury, that
describes the bounds of the illustration.
(The specification does not require the EPSF version, but many
programs will reject a file that does not have it.)
The EPS program must not use operators that initialize or
permanently change the state of the machine in a manner that cannot
be undone by the enclosing application's use of save and restore
(eg. the operators starting with ``init'' like initgraphics). As a
special case, the EPS program may use the showpage operator. The
importing application is responsible for disabling the normal
effects of showpage.
The EPS program should make no environment-sensitive decisions (the
importing application may be trying to attain some special effect,
and the EPS program shouldn't screw this up), although it can use
some device-dependent tricks to improve appearance such as a
snap-to-pixel algorithm.
The complete EPS specification is available from Adobe (see the
section on Adobe).
An optional component of an EPS file is a ``preview'' image of the
file's content. The preview image is a bitmapped representation of
the image which may be displayed by programs using the EPS file
without having to actually interpret the PostScript code.
The recommended form for a preview image is ``Interchange'' format
and is described fully in the ``red book'', second edition.
Interchange format represents the image as a series of hex strings
placed in the EPS file as PostScript comments. The entire file
remains an ASCII file.
A variation of EPS embeds the preview image and PostScript text in
a binary file which contains a header and the preview image in
either a TIFF or MetaFile format. The header defines where in the
file each section (EPS, TIFF, or MetaFile) starts and ends. On the
Macintosh, the preview is stored as a PICT in the file's resource
fork.
Subject: 9.2 What are EPSI and EPSF?
|
| EPSI is EPS with a device independent bitmap preview. EPSI is an
| all ASCII (no binary data or headers) version of EPS. EPSI provides
| for a hexadecimal encoded preview representation of the image that
| will be displayed or printed.
|
| EPSF is a version of EPS with a TIFF preview instead of a bitmap
| preview.
Subject: 9.3 How do I convert PostScript to EPS?
To convert from PostScript to EPS, one must guarantee that the
PostScript file meets the above requirements. If the actual program
conforms to the programming requirements, then one can simply add
the required comments at the top of the file saying that the file
is EPS and giving its BoundingBox dimensions.
Optional comments include font usage (%%DocumentFonts: or%%
DocumentNeededResources: font), EPSI preview comments (%%
Begin(End)Preview:) extensions (%%Extensions:) and language
level (%%LanguageLevel:).
There are some operators that should not be used within an EPS
file:
banddevice cleardictstack copypage erasepage
exitserver framedevice grestoreall initclip
initgraphics initmatrix quit renderbands
setglobal setpagedevice setshared startjob
These also include operators from statusdict and userdict operators
like legal, letter, a4, b5, etc.
There are some operators that should be carefully used:
nulldevice setgstate sethalftone setmatrix
setscreen settransfer undefinefont
To convert a PostScript file to EPS format, you must edit the file
using a text editor or word processor to add lines that will define
the file as an EPS-format file.
1. Using your normal method of printing, print the PostScript file
to a PostScript printer. You can choose to view it on the screen
instead, but keep in mind that all the below distance
measurements assume that you are printing on a normal-sized piece
of paper.
NOTE: If the PostScript image does not get displayed properly, it
probably will not work either once you have converted it to EPS
format. Correct the PostScript program so that it works before
you convert it to EPS format.
2. Use a tool (see below) to find the bounding box, which shows how
much space the PostScript image occupies when printed. You
specify the dimensions of the bounding box when you convert the
PostScript file to EPS format.
3. If you don't have a bounding box tool, you can just use a ruler
and draw one on your printout. With two horizontal lines and two
vertical lines, draw a box around the image that includes the
entire image while minimizing white space.
This box represents your bounding box. You may want to leave a
small amount of white space around the image as a precautionary
measure against minor printing problems, such as paper stretching
and paper skewing.
4. Measure distance ``a'' from the lower-left corner of the image to
the left edge of the paper.
5. Write the measurement in points. If your ruler does not show
points, calculate the total number of points: 1 inch = 72 points,
1 cm = 28.3 points, and 1 pica = 12 points. Designate this
measurement as ``measurement a.''
6. Measure distance ``b'' from the lower-left corner of the image to
the bottom edge of the paper.
Designate this measurement in points as ``measurement b.''
7. Measure distance ``c'' from the upper-right corner of the image
to the left edge of the paper.
Designate this measurement in points as ``measurement c.''
8. Measure distance ``d' from the upper-right corner of the image to
the bottom edge of the paper.
Designate this measurement in points as ``measurement d.''
9. Using any text editor, open the PostScript file for editing.
You'll see several lines of text. These lines are the PostScript
description of the image. The lines at the top of the file are
the header.
10. Add these lines to, or modify existing lines in, the header (the
first group of lines in any PostScript file):
%!Adobe-2.0 EPSF
%%Creator: name
%%CreationDate: date
%%Title: filename
%%BoundingBox: a b c d
Note: Make sure that the first line in the file is `` Also, do
not separate the header lines with a blank line space. The first
blank line that PostScript encounters tells it that the the next
line begins the body of the program.
For ``name,'' type your name or initials. For ``date,'' type
today's date using any format (for example, MM-DD-YY, MM/DD/YY,
July 5, 1987, and so on). For ``filename,'' type the name of the
PostScript file. After ``BoundingBox: ,'' type the measurements
you took in steps 3, 4, 5, and 6, separating each with a space:
``a'' is the measurement from Step 3, ``b'' is the measurement
from Step 4, ``c'' is the measurement from Step 5, and ``d'' is
the measurement from Step 6.
11. Save the file in text-only format.
If you are interested in learning how to further edit your
PostScript files, these books are available at most bookstores:
Understanding PostScript Programming and the green book.
Encapsulated PostScript is discussed in Appendix C of the old red
book. The new red book has a lot of information about Encapsulated
PostScript.
There will be a technical note available from Adobe called
'Guidelines for Specific Operators' that will talk about why some
operators are prohibited and how to use the others.
Subject: 9.4 How do I get the bounding box of a PostScript picture?
Use bbfig or epsinfo.ps.
Or if you would rather construct the bounding box by hand, use
Ghostview, which has a continuous readout of the mouse cursor in
the default user coordinate system. You simply place the mouse in
the corners of the figure and read off the coordinates.
Subject: 10 About The Comp.Lang.PostScript FAQ (and Usenet Guide to
PostScript)
Subject: 10.1 The PostScript FAQ: What is it?
The PostScript FAQ is a set of answers to frequently asked
questions (FAQs) that have appeared on the Usenet newsgroup
comp.lang.postscript. It is broken into many useful sections.
The Usenet Guide to PostScript is a larger set of help and answers
to PostScript questions, plus a tutorial for new users. It is still
in the process of being created. There is one file ``Exactly What
Does a Transformation Matrix Do?'', that is definitely not part of
the FAQ. Please send more!
I need help writing and revising answers for common questions
relating to PostScript. Almost all of the information in the
documents has been written by kind volunteers. The answers will be
published in either or both documents. A very long answer in the
Usenet Guide may be summarized, referred to briefly, or not
mentioned at all in the FAQ.
Subject: 10.2 How to get the FAQ files
The FAQ is available by anonymous ftp to
wilma.cs.brown.edu:pub/comp.lang.postscript/ You can get it
formatted in plain text ASCII, LaTeX, or PostScript.
I would be happy to email a copy of the FAQ in any format to you if
you do not have FTP.
Subject: 10.3 How to write a FAQ answer
I greatly appreciate your time and effort to help improve the
quality of the FAQ. Thank you for being willing to contribute!
* Please check to see if the topic is already in an FAQ. Perhaps
you really mean to submit a revision to an existing section.
* Start with a clear statement about what problem you are solving.
* Write for novice users, in ``tutorial format'', even if the
answer is meant for experienced programmers.
* Be specific when you make references.
* Be complete, and take the time to look over your draft and
revise.
* Answers should not be too wordy, unless you intend to write a
long answer for the Usenet Guide and have a shorter summary or a
pointer to the description placed in the FAQ. If you want to
write the summary yourself, thanks!
* Obviously, I cannot accept copyrighted material without
permission. Don't write the FAQ by paraphrasing from a
copyrighted book!
Subject: 10.4 The FAQ can contain LaTeX and PostScript inserts
The FAQ is actually written with LaTeX, so feel free to submit with
that text formatting language. There is a PostScript version of the
FAQ also, so feel free to send along PostScript pictures to
include.
Subject: 10.5 Revising the FAQ
Suggestions and comments are welcomed. My favorite way of receiving
a change suggestion is if you make a copy of the FAQ, edit the
copy, and mail me the modification, or a context diff (include the
version number).
Subject: 10.6 How to submit new information
If you know something that you think is worthwhile to be put in a
FAQ, definitely send it to me!
Don't hold back if your information is very specific. If there's
too much information to post I will archive it at an ftp site and
place a pointer to it in the FAQ.
Subject: 10.7 How to add a program description to the FAQ index
If the program is original, please send it to me, or tell me where
I can get it. Please put your name and email address at the top of
each file. Your program will be doubly useful if you clean up the
program so that other people can use it as an example to learn.
If the program was written by someone else, please send me just the
title, description, and where to get it. I may already have it.
For programs the FAQ needs to know:
* What is the name of the program?
* What does it claim to do, and does it do it well? Is it worth
using?
* Where is it available? What ftp sites can I get it from?
* How much does it cost? Is it free?
* What kinds of computers does it run on?
* Who is the author and does the author give an email address?
* Does it handle PostScript 2?
If the program is a PostScript interpreter, then the FAQ also needs
to know:
* Does it let you go backwards one page?
* Does it display the number of pages in the document?
* Does it let you print PostScript to a non-PostScript printer?
* What formats can it convert to?
Subject: 10.8 How to add a book description to the FAQ
For books the FAQ needs to know:
* What is the name of the book or document?
* What does it claim to do, and does it do it well? Is it worth
using?
* Can I get it on-line?
* Who wrote it? Does the author give an email address?
* Who is the publisher, and what is the copyright date?